package service

import (
	"github.com/quarkcloudio/quark-go/v2/pkg/builder"
	"github.com/wsl/hi-go/model"
	customTool "github.com/wsl/hi-go/plugins/customTool"
)

type ClassService struct{}

// 创建班级
func (studentService *ClassService) CreateClass(c *builder.Context) error {
	var class model.Class
	c.Bind(&class)
	// 检查参数是否合规，不合规提示默认提示语
	if _, err := customTool.CheckQueryV2(class); err != nil {
		return c.JSONError(err.Error())
	}
	if err := (&model.Class{}).Create(class.Name); err != nil {
		return c.JSONError(err.Error())
	}
	return c.JSONOk("操作成功")
}
